#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H

#include <QtGui>

QT_BEGIN_NAMESPACE
class QTextDocument;
QT_END_NAMESPACE


/* Parentheses matching */
struct ParenthesisInfo {
        char character;
        int position;
};

class TextBlockData : public QTextBlockUserData
{
    public:
            TextBlockData(){};
            QVector<ParenthesisInfo *> parentheses();
            void insert(ParenthesisInfo *info);

    private:
            QVector<ParenthesisInfo *> m_parentheses;
};



/* RagnaScript syntax highlighter */
class Highlighter : public QSyntaxHighlighter
{
    Q_OBJECT

    public:
        Highlighter(QTextDocument *parent = 0);
        QStringList importPatterns(const QString&);
        ~Highlighter();

    protected:
        void highlightBlock(const QString &text);

    private:
        struct HighlightingRule
        {
            QRegExp pattern;
            QTextCharFormat format;
        };
        QVector<HighlightingRule> highlightingRules;

        QRegExp commentStartExpression;
        QRegExp commentEndExpression;

        QTextCharFormat keywordFormat; /* commandes */
        QTextCharFormat labelFormat; /* Labels type "OnSomething:", "L_something:". */
        QTextCharFormat singleLineCommentFormat;
        QTextCharFormat multiLineCommentFormat;
        QTextCharFormat quotationFormat;
        QTextCharFormat numberFormat;
        QTextCharFormat functionFormat; /* Est considérée comme fonction tout mot suivi de ( */
        QStringList keywordPatterns;

        /* QFutureWatcher<QVector<int> > indexes; */
        /* QVector<int> getIndexes(const QString&, const HighlightingRule&); */
};

#endif
